function [result,p] = confidence_compare(interval,flag)
A = 0;                                                                     
B = 0;                                                                     
C = 0;                                                                     
f11 = interval(1);                                                         
f12 = interval(2);                                                         
f21 = interval(3);                                                         
f22 = interval(4);                                                         
w1 = f12 - f11;                                                            
w2 = f22 - f21;                                  
alfa = 0.5;
p = max([1-max([(f12-f21)/(w1+w2),0]),0]);
if p > alfa 
    A = A+1;
elseif p < 1 - alfa
    B = B+1;
else
    C = C+1;
end
re = [A,B,C];
[~,index] = max(re);
if flag == 1 
    if index == 1
        result = [f11 f12];
    elseif index == 2
        result = [f21 f22];
    else
        result = [f11 f12];
    end
else                
    if index == 1
        result = [f21 f22];
    elseif index == 2
        result = [f11 f12];
    else
        result = [f21 f22];
    end
end
end    
